﻿@using Framework.HtmlHelpers
@using WebUI.Areas.Admin.Models.Common
@using WebUI.Extensions
@using Domain
@model ListViewModel<EvaTask>
@{
	Layout = "~/Areas/Admin/Views/Shared/_AdminContent.cshtml";
}
@section head {
	<style>
		table tr td {
			vertical-align: middle !important;
		}
	</style>
}
@section body {
	<script src="~/dist/pview/pview.js"></script>
	<script>
		function showMessage(message, type) {
			$("#js-message").fadeIn();
			switch (type) {
				case -1:
					$("#js-message").attr("class", "alert alert-danger").find(".message").html(message);
					break;
				case 1:
					$("#js-message").attr("class", "alert alert-success").find(".message").html(message);
					break;
			}
			// 3s 后隐藏
			setTimeout(function () {
				$("#js-message").fadeOut("slow");
			}, 3000);
		}

		function search() {
			var query = $('#js-search-input').val();
			var queryType = $('#js-search-type').attr('search-type');
			window.location.href = window.location.origin + window.location.pathname + '?q=' + query + '&type=' + queryType;
		}

		var pview;
		$(function () {
			pview = new PView();
			pview.init();

			$('#js-search-input').on('keypress', function (event) {
				if (event.keyCode == "13") {
					search();
				}
			});
			$('#js-search-btn').on('click', function () {
				search();
			});
			$('#js-search-type-list li').on('click', function () {
				var type = $(this).attr('search-type');
				var typeName = $(this).find('a').html();
				$('#js-search-type').attr('search-type', type);
				$('#js-search-type').html(typeName);
			});
		});
	</script>
}

<!-- start 删除确认框 -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
				<h4 class="modal-title">确认框</h4>
			</div>
			<div class="modal-body">
				<form>
					<div class="form-group">
						<label for="message-text" class="control-label">确定要删除？</label>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
				<button onclick="deleteSubmit()" type="button" class="btn btn-primary" data-dismiss="modal">确认</button>
			</div>
		</div>
	</div>
</div>
<!-- end 删除确认框 -->
<!-- start 提示框 -->
@{ Html.RenderPartial("_MessagePartial"); }
<!-- end 提示框 -->

<input id="js-id" type="hidden" />

<!-- start .box -->
<div class="box">
	<!-- start .box-header -->
	<div class="box-header">
		<h3 class="box-title">列表</h3>

		<div class="box-tools">
			<div class="input-group input-group-sm" style="width: 250px;">
				<div class="input-group-btn">
					<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
						<span id="js-search-type" search-type="@(ViewBag.QueryType.Val)">@(ViewBag.QueryType.Text)</span>
						<span class="fa fa-caret-down"></span>
					</button>
					<ul id="js-search-type-list" class="dropdown-menu">
						<li search-type="name"><a href="javascript:;">任务名称</a></li>
						<li search-type="evataskcode"><a href="javascript:;">任务号</a></li>
						<li search-type="id"><a href="javascript:;">ID</a></li>
					</ul>
				</div>
				<input id="js-search-input" type="text" name="table_search" class="form-control pull-right" placeholder="Search" value="@ViewBag.Query">
				<div class="input-group-btn">
					<button id="js-search-btn" type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
				</div>
			</div>
		</div>
	</div>
	<!-- end .box-header -->
	<!-- start .box-body -->
	<!-- start 简单表格 -->
	<div class="box-body table-responsive no-padding">
		<table id="js-table" class="table table-hover" pview="table">
			<tr>
				<th>ID</th>
				<th>任务名称</th>
				<th>任务号</th>
				<th>开始时间</th>
				<th>结束时间</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
			@foreach (var cat in Model.List)
			{
				<tr data-tr-id="@cat.ID">
					<td>@cat.ID</td>
					<td>@cat.Name</td>
					<td>@cat.EvaTaskCode</td>
					<td>
						<span class="label label-info">@cat.StartDate</span>
					</td>
					<td>
						<span class="label label-info">@cat.EndDate</span>
					</td>
					<td>
						@switch (cat.Status)
						{
							case 1:
								<span class="label label-info">待开启</span>
								break;
							case 2:
								<span class="label label-info">正在评价</span>
								break;
							case 3:
								<span class="label label-info">评价结束</span>
								break;
							default:
								<span class="label label-info">未知</span>
								break;
						}
					</td>
					<td>
						<div class="btn-group" role="group" data-pjax>
							<a class="btn btn-primary" href="@Url.Action("ClassList")?evaTaskId=@cat.ID">进入</a>
						</div>
					</td>
				</tr>
			}
		</table>
	</div>
	<!-- end 简单表格 -->
	<!-- end .box-body -->
	<!-- start .box-footer -->
	<div class="box-footer clearfix">
		<div class="btn-group pull-left">
			<a class="btn btn-primary" href="@Url.Action("Create")">添加</a>
		</div>
		<!-- start 分页 -->
		<div id="js-page" pview="pages">
			<ul class="pagination pull-right" pview-btn-group pview-targets="table,pages">
				@Html.PageLinks(Model.PageInfo, i => Url.Action("Index", new { pageIndex = i, q = Request["q"], type = Request["type"] }))
			</ul>
		</div>
		<!-- end 分页 -->
	</div>
	<!-- end .box-footer -->
</div>
<!-- end .box -->
